Concerning the address_len parameter of accept and getpeername, in socket programming, it is inevitable that www.2cto needs to obtain peer information. comsocket provides two methods: accept () and getpeername () accept () intaccept (intsocket, s...
These functions either return a local protocol address (GETSOCKNAME) that is associated with a socket, or return the address of a foreign protocol associated with a socket (getpeername).
#include
int getsockname (int sockfd,struct sockaddr*
For server side:Bind with the port as a wildcard: for the server, bind (0,IP), after calling the bind function, you can call GetSockName to get the local port number of the serverWith the IP address as the wildcard address bind, only after accept
defines int getpeername (int s, struct sockaddr *name, socklen_t *namelen); Describes the offset address struct sockaddr_in sa that gets the socket; int len = sizeof (SA); if (!getpeername (SOCKFD, struct sockaddr *) &sa, &len)) {printf ("Other
How can I obtain the IP address of a specified interface in C?
The description of winsocket is as follows:
5.1.6 getsockname ()Brief description:Obtain the local name of a set of interfaces.
# Include ;
Int Pascal far getsockname (socket S, struct
1 socket functionIn order to perform network I/O, the first thing a process must do is call the socket function, specifying the desired type of communication protocol#include int socket (intintint protocol);//返回:若成功则为非负描述符,若出错则为-1Where family
Explanation of the entire communication process of the python select. select module,
To understand the select. select module, we mainly need to understand its parameters and its three return values.The select () method receives and monitors three
1. TCP is a reliable connection-oriented protocol. Before one Party sends data, a connection must be established between the two parties. The process of establishing a connection must undergo three handshakes. After the communication is complete,
Zombie Process processing under concurrentWith only one process connected, we can handle the zombie process in two ways:1) Avoid the zombie process by ignoring the SIGCHLD signalAdding in server-side codeSignal (SIGCHLD, sig_ign);2) solve the zombie
This article describes the differences between select, poll, and epoll by analyzing pythonselectepollpoll.
Select
Select first appeared in. it monitors arrays of multiple file descriptors through a select () system call (everything in linux is a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.